Add the pure query core for the analysis catalog - #211
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds a pure analysis catalog query core, search folding, row construction, facets, filters, sorting, and a memoized Redux selector. It also adds tests for catalog behavior, normalization, query operations, and selector memoization. ChangesAnalysis catalog
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AnalysisState
participant selectCatalogRows
participant buildCatalogRows
AnalysisState->>selectCatalogRows: token analyses, links, language, current book
selectCatalogRows->>buildCatalogRows: catalog scope
buildCatalogRows-->>selectCatalogRows: catalog rows
selectCatalogRows-->>AnalysisState: memoized row collection
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
alex-rawlings-yyc
left a comment
There was a problem hiding this comment.
@alex-rawlings-yyc resolved 2 discussions.
Reviewable status: 0 of 7 files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).
35e2980 to
7e0162a
Compare
imnasnainaec
left a comment
There was a problem hiding this comment.
Synthesized review, not human-checked.
Authored by Claude Opus 5 (1M context) (claude-opus-5[1m]) running in Claude Code. It is a synthesis of Devin's review of this PR: every finding was re-read against the branch, and the ones that were stale, incorrect, or purely informational were dropped — but no human has verified what remains. Treat each comment as a suggestion to evaluate rather than a request.
Behavioral claims were checked by running the actual fold pipeline and Canon.bookIdToNumber on Node 22; the measured values are quoted inline. Comments prefaced with :pick: are low-priority or optional.
Row derivation, search fold, and facets, memoized as selectCatalogRows. Row building and query application are separate functions so searching and sorting never rebuild rows; the search fold stays apart from normalizeSurfaceForm, since folding a diacritic into identity would silently merge distinct analyses.
Adds pos, confidence, and feature filters, treats an empty selection as inactive, and orders the confidence facet by strength. The search query is trimmed in applyCatalogQuery, not in foldForSearch, whose output separates the row fields a match must not span.
Compatibility normalization covers the shapes Unicode encodes as variants; Greek and Hebrew final letters, which it encodes as distinct letters, are mapped.
Ties fell through to payload creation order, so a draft of mostly one-usage rows was ordered by when each analysis happened to be recorded; they now fall back to form, then gloss.
The analyses and links these fixtures build gained required createdAt / updatedAt, so each now spreads FIXTURE_STAMPS. Also drops two fixture counts from the doc comments, which nothing kept in sync.
Absence now lists as undefined after a field's values, so a field one analysis is tagged with still raises a dropdown, and a search for what an analysis lacks is possible. Also folds a pasted Windows line ending in a catalog search.
Usage counts match the suggestion pool's frequency only while a token carries at most one approved link, and a single-book draft is offered no books facet even when unused rows sit alongside the used ones.
7187fd9 to
753e4fa
Compare
Cache the fold per analysis record, count a token once however many approved links carry it, and keep a field's own line break from spelling the separator a match may not span.
alex-rawlings-yyc
left a comment
There was a problem hiding this comment.
Addressed all comments left
@alex-rawlings-yyc made 12 comments.
Reviewable status: 0 of 7 files reviewed, 11 unresolved discussions (waiting on alex-rawlings-yyc and imnasnainaec).
A gloss of only whitespace counts as missing, the reading the rest of the analysis layer takes, and the query is trimmed after folding, by which point a spacing diacritic has decomposed to a bare space.
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed 4 files and all commit messages, made 2 comments, and resolved 8 discussions.
Reviewable status: 4 of 7 files reviewed, 6 unresolved discussions (waiting on alex-rawlings-yyc).
src/utils/search-fold.ts line 11 at r5 (raw file):
I find this comment to be unclear as to whether the mapping is to or away from the word-final form. Perhaps something like:
Letter shapes that are only used at the end of a word, mapped to the default shape used everywhere else.
src/__tests__/utils/analysis-query.test.ts line 190 at r5 (raw file):
}); // The morpheme form is suppletive, so a match cannot come from the surface form instead.
⛏️ I don't find this comment helpful.
Only CR and LF collapsed, so a gloss broken with a vertical tab or a line separator was unfindable by a spaced query. Also settles the direction of the final-letter map and narrows the usage-count and fold-cache docs to what they guarantee.
alex-rawlings-yyc
left a comment
There was a problem hiding this comment.
@alex-rawlings-yyc made 6 comments.
Reviewable status: 4 of 7 files reviewed, 6 unresolved discussions (waiting on alex-rawlings-yyc and imnasnainaec).
src/__tests__/utils/analysis-query.test.ts line 190 at r5 (raw file):
Previously, imnasnainaec (D. Ror.) wrote…
⛏️ I don't find this comment helpful.
Deleted.
src/utils/search-fold.ts line 11 at r5 (raw file):
Previously, imnasnainaec (D. Ror.) wrote…
I find this comment to be unclear as to whether the mapping is to or away from the word-final form. Perhaps something like:
Letter shapes that are only used at the end of a word, mapped to the default shape used everywhere else.
Fair — the old subject was the letter, which has both shapes, so it left the key
ambiguous. Making the word-final shapes the subject settles it.
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed 3 files and all commit messages, and resolved 6 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).
Closes #192.
The pure derivation layer for the Analysis Catalog (#186) — no React, no store, no PAPI, no UI.
Modules
src/utils/search-fold.ts—foldForSearch(NFKD → strip\p{Mn}→ NFC → lowercase → fold final letter forms), kept deliberately apart fromnormalizeSurfaceForm. NFKD folds compatibility distinctions generally — ligatures, width and superscript variants, non-breaking spaces — not just positional shapes.src/utils/analysis-query.ts—buildCatalogRows,applyCatalogQuery,deriveFacets.src/store/analysisSlice.ts—selectCatalogRows(state, currentBook), memoized on the two token-level arrays plus the analysis language and book.Three divergences from the issue, agreed before implementing
buildCatalogRows(analysis, query)but also requires search/sort/filter to run outside the memoized build — those conflict. Shipped asbuildCatalogRows(analysis, scope)+applyCatalogQuery(rows, query).buildCatalogRowstakesPick<TextAnalysis, 'tokenAnalyses' | 'tokenAnalysisLinks'>so the selector memoizes on those arrays rather than the wholeTextAnalysis.CatalogRowcarriespos/features/confidence. The row shape in Analysis catalog: pure query core (analysis-query.ts, search fold, memoized selector) #192 has none of them, soderiveFacets(rows)could not derive the facets it is asked to.statusand lexicon refs are deliberately not facets: status is constant by construction (only approved links count as usages) and lexicon-ref presence is a boolean, not a value list.analysisLanguagesin the query.searchTextfolds every gloss value present, so a gloss in a language the project no longer declares stays findable.#192 and #186's row model should be amended before #193 starts, since #193 consumes these exports.
Not in the issue, but the data requires it
USJ verse SIDs are verbatim, so a bridged verse arrives as
"GEN 1:3-4:0"andNumber('3-4')isNaN. Usage parsing goes through the existingfirstVerseNumber; there is a test for it.Testing
Covers every behavior #192 lists, plus the script-specific cases the search fold turns on. Full suite passing, 100% coverage, lint clean.
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
New Features
Tests